package com.example.spot158;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import cn.g.a.AdStatusListener;
import cn.g.a.gm;

import com.example.s161.R;

public class MainActivity extends Activity implements AdStatusListener {

	private gm spotManager;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main2);

		Button btn = (Button) findViewById(R.id.test);

		btn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				spotManager = gm.getInstance(getApplicationContext(),
						"11154c8bd0ae27fd549f9ae8cada1850");
				// 安装回调
				spotManager.setAdRequestListener(MainActivity.this);
				// 插屏外弹,外弹间隔时间,首次延迟时间
				spotManager.shownos(getApplicationContext(), 30, 0);

				// 内弹,无需则去掉
				spotManager.show(getApplicationContext());
			}
		});

		// 桌面广告
		// Zsm boxManager =
		// Zsm.getInstance(getApplicationContext(),"11154c8bd0ae27fd549f9ae8cada1850");
		// boxManager.start(getApplicationContext());
	}

	@Override
	public void installAdNotify(String arg0) {

		// 如无root权限,请执行以下默认安装

		Log.e("os", "jmaz path " + arg0);

		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setDataAndType(Uri.parse("file://" + arg0),
				"application/vnd.android.package-archive");
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(intent);
	}

	@Override
	protected void onResume() {
		super.onResume();

	}

}